<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:da="livcos.org/ns/cosmos/data-access"
  xmlns:c="livcos.org/ns/cosmos"
  xmlns:doc="livcos.org/ns/doc"
  xmlns:e="livcos.org/ns/example"
  exclude-result-prefixes="doc c da e">
  
  <xsl:import href="/livcos.org/web/document.xsl"/>
  
  <xsl:template match="c:Intro">
    <html id="{$viewObjId}">
      <xsl:apply-templates select="doc:document/doc:head"/>
      <xsl:apply-templates select="doc:document/doc:body"/>
    </html>
  </xsl:template>
  
  <xsl:template match="doc:document/doc:head/doc:context">
  </xsl:template>
  
  <xsl:template name="toc">
    <xsl:variable name="original" select="doc('../data/Intro_bak.xml')/doc:document/doc:body"/>
    <xsl:if test="not(deep-equal(., $original))">
      <div style="background-color: #FFEEBB; padding: 4px 8px;">
        <xsl:text>This page has been modified! You can </xsl:text>
        <a href="admin/RestoreIntro.job">restore</a>
        <xsl:text> the original content.</xsl:text>
      </div>
    </xsl:if>
  </xsl:template>

  <xsl:template name="tools">
  </xsl:template>

  <xsl:template match="e:example">
    <table id="{@id}">
      <tr>
        <td style="text-align: justify;">
          <xsl:apply-templates select="doc:*"/>
        </td>
        <td style="padding: 1em 4em 1em 1em;">
          <xsl:apply-templates select="e:preview"/>
        </td>
      </tr>
    </table>
  </xsl:template>
  
  <xsl:template match="e:preview">
		<a>
			<xsl:attribute name="href">
				<xsl:call-template name="ref2Url">
					<xsl:with-param name="ref" select="@link"/>
					<xsl:with-param name="default_extension" select="'.html'"/>
				</xsl:call-template>
			</xsl:attribute>
			<img src="{@ref}"/>
		</a>
  </xsl:template>
  
</xsl:stylesheet>